#include <iostream>

using namespace std;

bool isprime(int x)
{
	if (x <= 1) return false;
	for (int i = 2; i <= x / i; i++)
		if (x % i == 0) return false;
	return true;
}
int main()
{
	int n; cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int x; cin >> x;
		if (isprime(x)) cout << x << " ";
	}
	cout << endl;
	return 0;
}